package com.learning.demos.jvmgc;

import java.util.ArrayList;
import java.util.List;

/**
 * @author adolphw
 *
 * 垃圾回收过头了，一直进行垃圾回收，cpu标高
 *
 * -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:MaxDirectMemorySize=5m
 */
public class OOMGCOverHeadDemo {

    public static void main(String[] args) {
        int i = 0;
        List<String> list = new ArrayList<>();

        try {
            while (true) {
                list.add(String.valueOf(++i).intern());
            }
        } catch (Exception e) {
            System.out.println("===================i" + i);

            e.printStackTrace();
        }

    }
}
